Learning Objectives

After completing this lesson, you’ll be able to:

Custom Transformer Types

There are two types of custom transformers.

Workspaces store the definition of embedded transformers in the workspace itself. Each instance of the custom transformer refers to that embedded definition. Only the workspace with the embedded transformer has access to that custom transformer.

linked transformer has its definition stored outside the workspace in a separate file. Each instance of a linked transformer relies on that external definition. Any workspace can have access to that custom transformer.

On a workspace canvas, embedded transformers are identified by their green color, while linked transformers are colored cyan:

Embedded versus linked custom transformers

Linked vs. Embedded Transformers

You can use both types of transformers in an FME workspace, and each type has various advantages and disadvantages.

Embedded Transformers

Embedded transformers are easier to manage, need no external files, and store their definition directly in the workspace. They are handy for tidying a workspace and employing advanced functionality like parallel processing.

However, sharing and re-using content is more complex with an embedded transformer. You can only easily share the custom transformer with other users if you give them a copy of the same workspace. Additionally, it takes work to maintain a consistent definition among several users.

Linked Transformers

Linked transformers are a little more complicated to manage. They exist as a file (.fmx) outside of the workspace, which is less convenient, and when used to employ advanced functionality such as loops, they can be more complex.

However, a linked custom transformer is a little easier to edit (you open the .fmx file rather than the .fmw file) and is much easier to share among users. The file can be given to any FME author, and any number of authors can point their workspace to the same custom transformer file.

Sharing the same file is useful because any changes to the definition automatically propagate to all workspaces that use it.

Like embedded transformers, linked transformers appear in the transformer gallery and Quick Add dialog. Also, notice that they have a special icon to signify that you are about to use a linked version rather than the embedded version:

Linked transformer in the Transformer Gallery

Creating a Linked Custom Transformer

All custom transformers start with an embedded definition. To create an external definition, export the custom transformer using the Export as Custom Transformer option on the menu bar:

Creating a linked custom transformer via File > Export As Custom Transformer...

At this point, a dialog opens in which you can confirm the transformer name and category, plus some other parameters, including the save location:

Export as Custom Transformer dialog

Name and category are straightforward, so let’s look at other options.

Insert Mode

We know that the definition of a custom transformer can be stored either in a workspace (embedded) or in a separate file (linked). Therefore, each instance of a custom transformer points to an embedded or linked definition.

But it’s important to know that each instance can change its definition source. For example, you can switch an instance of a custom transformer linked to a file definition to embedded (in which case the external definition gets embedded into the workspace).

Likewise, you can switch an instance that points to an embedded definition to point to an external file.

As the author of a custom transformer, I might want to control the initial state when I place an instance. The Insert Mode parameter controls this behavior.

There are four different modes:

Transformer Insert Modes

Let’s say I export my custom transformer with Insert Mode set to one of the Embedded choices. An FMX file now stores the definition, and FME will recognize it as an available transformer. But when a user places a new instance in their workspace (say with Quick Add or the Transformer Gallery), the definition of the custom transformer is copied from the FMX file and embedded into the workspace.

If I choose Embedded By Default, although each transformer instance starts as Embedded, the user can switch the instance to “Linked” at any point.

If I choose Embedded Always, each transformer instance starts as embedded and must stay that way. A user cannot switch it to Linked at a later point.

Similarly, I could export my custom transformer in Linked mode. When a user places a new instance, the definition of the transformer remains in my FMX file, with the instance linked to it.

If I choose Linked By Default, each instance of the transformer starts as Linked but can be switched to Embedded at any time.

If I choose Linked Always, each instance starts as Linked and stays that way. To cannot be switched to Embedded at a later point.

Note

Insert Mode is an important parameter when I am the author of a custom transformer who has created it for other workspace authors. It gives me control over how they will use that transformer.

Which Mode to Use

Embedded Always is a good choice when the person using the transformer is less experienced with FME; it’s easier to manage, and if they make changes, they won’t affect other people. Embedded is also a good choice when you intend for individuals to use the custom transformer (i.e., not sharing it as a group).

Linked Always is a good choice when you intend for a group of users to share the custom transformer. Because it is linked, the users will always receive updates if the transformer definition is changed, and because the definition is shared, it becomes a standard applied to all users.

Only when the end-user is experienced in FME and can understand the consequences is it advisable to use a “By Default” setting and allow type switching.

Password

The password field allows you to password-protect the custom transformer. This setting makes it impervious to edits from unauthorized persons. Additionally, the contents are (very mildly) encrypted, so unauthorized users cannot copy them by opening the source file in a text editor.

This setting allows authors to make transformers available for purchase without fear of copying or editing their work. Of course, it’s essential not to forget or lose the password yourself if you wish to make edits!

Save Location

FME has a specific installation folder where it saves custom transformer files. If you save custom transformers in this folder, you can find them in Workbench and use them like any other transformer. If you save transformers elsewhere, you won’t be able to find them in Workbench unless you add the path under Tools > FME Options > Default Paths.

Editing a Linked Custom Transformer

When you click the OK button on the Export as Custom Transformer dialog, FME exports the transformer to a separate (.fmx) file. That file is immediately opened inside a new instance of FME Workbench for you to make edits.

Essentially, editing a custom transformer works like editing a workspace: you open the file in FME Workbench and edit as required.

The critical part to remember is that any changes you make will affect each instance of the Custom Transformer linked to this file.

Note

Searching for bugs in an embedded custom transformer before exporting it is best. That’s because tools such as Feature Caching and Run with Breakpoints do not work inside exported transformers.

Switching Custom Transformer Types

The action is very straightforward when the Insert Mode of a custom transformer allows type switching. Right-click on the instance and choose the required type:

Right-click > Link for custom transformers

In the above screenshot, the user is switching from Embedded to Linked. Of course, switching to Linked requires the custom transformer to be exported already.

When you switch from embedded to linked, the embedded definition is closed. The transformer instance then points to the linked definition.

When you switch from linked to embedded, the contents of the FMX file are copied and embedded in the workspace. The transformer instance then points to the embedded definition.

If there is more than one instance of the Custom Transformer, FME asks whether you want to switch all of them:

Multiple Transformers Found warning

The usual answer is yes because having the same embedded and linked transformer could be confusing! If you answer no, then be aware that the transformer you clicked on will be linked (but none of the other instances will).

Note

Switching from Embedded to Linked only works if you have not modified the embedded transformer.

In other words, if you embed a linked transformer and then make changes to the embedded definition, you won’t be able to revert to the linked version.